<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 200px;
        font-size: 18px;
        font-weight: bold;
    }
    .layui-form .layui-form-item .layui-inline .layui-input-inline{
        font-size: 18px;
        line-height: 40px;
    }

</style>
<form class="layui-form  seller-alone-form" id="userAdd" style="padding:20px;min-height: 600px;height: auto">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>
            <a href="{:url('index')}" style="color: #428bca;font-weight:bold;" >Product Manage</a> / Edit
        </legend>
    </fieldset>
    <br/>

    <div class="layui-form-item">
        <div class="layui-inline" >
            <label class="layui-form-label">Product Token：</label>
            <div class="layui-input-inline" style="width: 400px;">
                {$data.product_token}
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline" >
            <label class="layui-form-label">Product Name：</label>
            <div class="layui-input-inline" style="width: 400px;">
                {$data.name}
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline" >
            <label class="layui-form-label">Update Cards Product：</label>
            <div class="layui-input-inline" style="width: 400px;">
                    <textarea name="update_desc" style="padding-left: 2px;"
                              class="layui-textarea"></textarea>
            </div>
        </div>
    </div>
    <br/>
    <div class="layui-form-item" style="padding-top: 30px;">
        <div class="layui-input-block">
            <input type="hidden" name="product_id" id="product_id" value="{$data.id}">
            <button type="button" class="layui-btn" lay-submit lay-filter="edit">Edit Product</button>
            <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            <br/>
            <br/>
            <br/>
            <button type="button" class="layui-btn" lay-submit lay-filter="search">Search Product Info</button>
            <button type="button" class="layui-btn" lay-submit lay-filter="search_source">Search Source Info</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form'], function () {
        var form = layui.form;
        form.render();
        form.on('submit(edit)', function(data){
            JsPost("{:url('productEdit')}", data.field, function(res){
                if(res.code){
                    layer.msg(res.msg,{icon: 1, time: 1500});
                }else{
                    layer.msg(res.msg,{icon: 2, time: 1500});
                }
            })
        });
        form.on('submit(search)', function(){
            JsGet("{:url('showDetail')}?type=product&product_id="+ $("#product_id").val(), function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Product Info',
                        area: ['1000px', '600px'], //宽高
                        content: e.datas,
                        btn:['Close']
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
        form.on('submit(search_source)', function(){
            JsGet("{:url('showDetail')}?type=source&product_id="+ $("#product_id").val(), function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Product Info',
                        area: ['1000px', '600px'], //宽高
                        content: e.datas,
                        btn:['Close']
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
    });
</script>
